#include "juliathread.h"

JuliaThread::JuliaThread(QObject *parent)
    : RenderThread(parent)
{
}

int JuliaThread::pointIteration(Complex z, int k, const Complex &c)
{
    int i;
    double R = MAX(c.abs(), 2);
    
    for (i = 0; z.abs() <= R && i < k; ++i) {
        z = (z^2) + c;
	//z = (z^4) - (c*(z^2)) + c;
    }

    return i;
}

int JuliaThread::pointIteration(double x, double y, int k, double cr, double ci)
{
    int i;
    double R2 = MAX(cr*cr + ci*ci, 2*2);

    for (i = 0; i < k; ++i) {
        double x2 = x*x;
        double y2 = y*y;
        if (x2 + y2 > R2)
            break;
        y = 2*x*y + ci;
        x = x2 - y2 + cr;
    }
    return i;
}
